package com.meida.module.bus.provider.handler;

import cn.hutool.core.util.ObjectUtil;
import com.meida.common.base.entity.EntityMap;
import com.meida.common.mybatis.interceptor.UpdateInterceptor;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaUpdate;
import com.meida.common.security.OpenHelper;
import org.springframework.stereotype.Component;

/**
 * @author lidd
 * @description: 用户个人信息修改
 * @date: 2022年-06月-23日  00:06:42
 */
@Component("appUserInfoUpdateHandler")
public class AppUserInfoUpdateHandler implements UpdateInterceptor {


    @Override
    public ResultBody validate(CriteriaUpdate cu, EntityMap params) {
        return ResultBody.ok();
    }

    @Override
    public void prepare(CriteriaUpdate cu, EntityMap params, Object o) {

        cu.setIdValue(OpenHelper.getUserId());
        cu.set(ObjectUtil.isNotNull(params.get("nickName")), "nickName", params.get("nickName"));
        cu.set(ObjectUtil.isNotNull(params.get("wechatNo")), "wechatNo", params.get("wechatNo"));
        cu.set(ObjectUtil.isNotNull(params.get("avatar")), "avatar", params.get("avatar"));

    }


}
